package org.sixtynine.stock.service.impl;

import java.util.List;

import org.sixtynine.stock.dao.QuarterlyShareDataDao;
import org.sixtynine.stock.dto.GridPramDTO;
import org.sixtynine.stock.dto.Page;
import org.sixtynine.stock.entity.QuarterlyShareData;
import org.sixtynine.stock.service.QuarterlyShareDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Thilan
 * 
 */

@Service
public class QuarterlyShareDataServiceImpl implements QuarterlyShareDataService {

	@Autowired
	private QuarterlyShareDataDao quarterlyShareDataDao;

	@Override
	public QuarterlyShareData findById(int id) {
		return quarterlyShareDataDao.findById(id);
	}

	@Override
	@Transactional(readOnly = false)
	public void saveQuarterlyShareData(QuarterlyShareData quarterlyShareData) {
		quarterlyShareDataDao.saveQuarterlyShareData(quarterlyShareData);
	}

	@Override
	@Transactional(readOnly = false)
	public void deleteQuarterlyShareData(int id) {
		QuarterlyShareData quarterlyShareData = quarterlyShareDataDao
				.findById(id);
		if (quarterlyShareData != null) {
			quarterlyShareDataDao.delete(quarterlyShareData);
		}
	}

	@Override
	public List<QuarterlyShareData> findQuarterlyShareData(int companyId) {
		return quarterlyShareDataDao.findQuarterlyShareData(companyId);
	}

	@Override
	public List<QuarterlyShareData> searchQuarterlyShareData(int companyId,
			int fromDate, int toDate, String quarterCode, String orderBy,
			String orderByName) {
		return quarterlyShareDataDao.searchQuarterlyShareData(companyId,
				fromDate, toDate, quarterCode, orderBy, orderByName);
	}

	@Override
	public Page<QuarterlyShareData> searchQuarterlyShareData(int companyId,
			String companyName, int fromDate, int toDate, String quarterCode,
			String orderBy, String orderByName, GridPramDTO gridPramDTO) {
		return quarterlyShareDataDao.searchQuarterlyShareData(companyId,
				companyName, fromDate, toDate, quarterCode, orderBy,
				orderByName, gridPramDTO);
	}

	@Override
	public void deleteQuarterlyShareData(int companyId, int fromYear,
			int toYear, String quarterCode) {
		quarterlyShareDataDao.deleteQuarterlyShareData(companyId, fromYear,
				toYear, quarterCode);
	}

}
